package com.agrm.utils;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Random;

public class TimestampGenerator {

    private static int sequence = 0;
    public static synchronized String generateCustomId() {
        LocalDateTime now = LocalDateTime.now();
        String timePart = now.format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss"));
        int seq = sequence++ % 1000;
        long random = new Random().nextLong() % 100000000000L;
        if (random < 0) random = -random;
        return timePart + String.format("%03d", seq) + String.format("%011d", random);
    }

}
